package com.aldobucchi.range
{



	public class Range
	{
		
		//////////////////////////////////////
		// minInclusive
		//////////////////////////////////////
		
		private var _minInclusive:Boolean;
		
		public function get minInclusive( ):Boolean
		{
			return _minInclusive;
		}
		
		
		//////////////////////////////////////
		// maxInclusive
		//////////////////////////////////////
		
		private var _maxInclusive:Boolean;
		
		public function get maxInclusive( ):Boolean
		{
			return _maxInclusive;
		}
		
		
		
		
		
		
		
		//////////////////////////////////////
		// min
		//////////////////////////////////////

		private var _min:Number;
		
		public function get min( ):Number
		{
			return _min;
		}
		
		
		
		//////////////////////////////////////
		// max
		//////////////////////////////////////
		
		private var _max:Number;
		
		public function get max( ):Number
		{
			return _max;
		}
		
		


		public function Range( min:Number, max:Number, minInclusive:Boolean=true, maxInclusive:Boolean=true )
		{

			if ( min > max )
			{
				_max = min;
				_maxInclusive = minInclusive;
				_min = max;
				_minInclusive = maxInclusive;
			}
			else
			{
				_min = min;
				_minInclusive = minInclusive;
				_max = max;
				_maxInclusive = maxInclusive;
			}

		}
		
		


		
		public function containsValue( value:Number ):Boolean
		{
			
			if ( value > _min && value < _max )
				return true;
				
			if ( _minInclusive && value == _min )
				return true;
				
			if ( _maxInclusive && value == _max )
				return true;
			
			return false;

		}
		
		
		
		public function toString( ):String
		{
			var arr:Array = new Array( );
			arr.push( minInclusive ? "[" : "]" );
			arr.push( min );
			arr.push( "," );
			arr.push( max );			
			arr.push( maxInclusive ? "]" : "[" );			
			return arr.join( " " );
		}
		
		
		

	}
}




